package pip;

import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;

import org.apache.commons.digester.Digester;
import org.xml.sax.SAXException;

import com.keithpower.gekmlib.*;

/**
 * Simple example, showing how to load and print a KML file
 * @author Keith Power March 2007
 * @version 0.01
 */

public class LoadExample
{
    public static void main(String[] args)
    {
	KMLParser parser = new KMLParser();
	try
	{
	    /**
	     * You probably don't want IDs auto-generated when you're loading
	     * a document. You can always turn it back on later.
	     * NOTE: KML updates will only work for objects that have
	     * an ID (either autogenerated or assigned).
	     */
	    Configuration.properties.setProperty(Configuration.GENERATE_IDS, Configuration.OFF);
	    
	    /**
	     * Load the document into a Kml object.
	     */
	    Kml ge = parser.parse(new File("whale_shark.kml"));
	    System.out.println(ge.toKML());	    
	} catch (IOException e)
	{
	    // Just fail
	    System.err.println("Error reading file "+e);
	} catch (SAXException e)
	{
	    // Just fail
	    System.err.println("Error parsing "+e);
	}
    }
    
}
